﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinCustomsService
{
    public class Utils
    {
        /// <summary>写入 UTF-8 编码的文本文件，不存在时将自动创建该文件</summary>
        /// <param name="text">要写入的文本内容</param>
        /// <param name="fileName">文件名</param>
        public static void WriteTextFile(string text, string fileName)
        {
            using(var sw = new StreamWriter(fileName, true, Encoding.UTF8))
                sw.Write(text);
        }

        public static string GetMapPath(string path)
        {
            var _path = path.Replace('/', '\\');
            _path = _path.TrimStart('~', '\\');
            return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _path);
        }
    }
}
